package com.javalong.affairs.base.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.javalong.affairs.R;
import com.javalong.affairs.base.ui.QSToolbar;


/**
 * Created by 杨观回 on 2015/12/29 0029.
 * 有Toolbar的activity
 */
public abstract class ToolbarActivity extends BaseActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initLayout();
        initToolbar();
        initData();
    }

    /**
     * 初始布局文件，或者布局view
     */
    protected abstract void initLayout();


    /**
     * 获取intent传递过来的数据或者，自己请求数据
     */
    protected abstract void initData();

    /**
     * 初始化工具栏
     */
    protected void initToolbar() {
        QSToolbar toolbar = (QSToolbar) findViewById(R.id.tb_tool);
        toolbar.setNavigationIcon(R.drawable.back);
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }

}
